{extend name="base" /}
{block name="title"}后台管理-用户管理{/block}
{block name="main"}
<div class="widget-body">
    <div class="span6">
        <div id="users_length" class="dataTables_length">
            <label>Entries:
                <select size="1" name="users_length" aria-controls="users">
                    <option value="10" selected="selected">10</option>
                    <option value="25">25</option>
                    <option value="50">50</option>
                    <option value="100">100</option>
                </select>
            </label>
        </div>
    </div>
    <div class="span6">
        <div class="dataTables_filter" id="users_filter">
            <label>Search:
                <input type="text" aria-controls="users" name="Search">
            </label>
        </div>
    </div>
    <table id="user" class="table table-striped table-bordered dataTable">
        <thead>
            <tr>
                <th>昵称</th>
                <th>学号</th>
                <th>电话</th>
                <th>学校</th>
                <th>状态</th>
                <th></th>
            </tr>
        </thead>
        <tbody class="userlist">
            {volist name="usersa" id="vo"}
            <tr>
                <td>{$vo.name}</td>
                <td>{$vo.sNumber}</td>
                <td>{$vo.teleNumber}</td>
                <td>{$vo.schoolName}</td>
                <td>
                    {if condition="$vo.status == 0"}
                    <span class="label label-success slabel" data-uid="{$vo.userId}" data-status='0'>正常</span>
                    {else/}
                    <span class="label slabel" data-uid="{$vo.userId}" data-status='1'>禁用</span>
                    {/if}
                </td>
                <td>
                    <div class="btn-group">
                        <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
                            操作
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="{:url('resetpw',['uid'=>$vo.userId])}"><i class="icon-wrench"></i> 重置密码</a>
                            </li>
                            <li><a href="{:url('edituser',['uid'=>$vo.userId])}"><i class="icon-edit"></i> 修改</a></li>
                            <li><a href="{:url('deluser',['uid'=>$vo.userId])}"><i class="icon-trash"></i> 删除</a></li>
                        </ul>
                    </div>

                </td>
            </tr>
            {/volist}
        </tbody>
    </table>
    <div class="dataTables_paginate paging_bootstrap pagination">
        <ul>
            <li class="prev disabled">
                <a href="#">← Previous</a>
            </li>
            <li class="active">
                <a href="#">1</a>
            </li>
            <li class="next disabled">
                <a href="#">Next → </a>
            </li>
        </ul>
    </div>
</div> <!-- /widget-body -->
<script src="__STATIC__/assets/js/jquery.min.js"></script>
<script>
    $("[name='Search']").on("change", function () {
        console.log($(this).val());
        let key = $(this).val();
        $.ajax({
            type: 'post',
            url: "{:url('User/keyword')}",
            data: {
                "key": key,
            },
            success: function (data) {
                console.log(data);
                data.forEach(element => {
                    console.log(element['name']);
                });
            },
            error: function (error) {
                console.log(error);
            }
        });
    });
</script>
{/block}
